#include <iostream>

using namespace std;


struct ListNode {
	int val;
	ListNode *next;
	ListNode(int x) : val(x), next(NULL) {}
};

class Solution
{
public:
	ListNode *swapPairs(ListNode *head) 
	{
		// Start typing your C/C++ solution below
		// DO NOT write int main() function
		if(!head)
			return NULL;

		ListNode *pre = NULL, *first = head, *second = head->next;
		while(first && second)
		{
			if(pre)
			{
				pre->next = second;
			}
			first->next = second->next;
			second->next = first;

			if(!pre)
				head = second;
			pre = first;
			first = first->next;
			if(first)
				second = first->next;
			else
				break;
		}        
		return head;
	}
};


int main()
{
	int n;
	Solution s;
	while(cin>>n)
	{
		if(n==0)
			break;
		
		
		ListNode *head = NULL;
		ListNode* current = NULL;
		for(int i=0;i<n;i++)
		{
			if(!current)
			{
				head = current = new ListNode(0);
			}
			else
			{
				current->next = new ListNode(0);
				current = current->next;
			}
			cin>>current->val;
		}

		current = s.swapPairs(head);
		while(current)
		{
			cout<<current->val<<" ";
			current = current->next;
		}		
		cout<<endl;
	}
}